		package adapter;

import java.util.Observable;
import java.util.Observer;

import be.kuleuven.cs.swop.api.IEmergency;
import be.kuleuven.cs.swop.api.ITime;
import be.kuleuven.cs.swop.api.IUnit;
import be.kuleuven.cs.swop.external.ExternalSystemException;

public class AExternalSystem implements be.kuleuven.cs.swop.external.IExternalSystem, Observer {

	@Override
	public void notifyAssignment(IUnit unit, IEmergency event)
			throws ExternalSystemException, IllegalArgumentException {
		AUnit aunit =(AUnit)unit;
		AEmergency aemergency = (AEmergency)event;
		aunit.getUnit().assignEmergency(aemergency.getEmergency());
	}

	@SuppressWarnings("unused")
	@Override
	public void notifyRelease(IUnit unit, IEmergency event)
			throws ExternalSystemException, IllegalArgumentException {
		try {
			AUnit aunit =(AUnit)unit;
			AEmergency aemergency = (AEmergency)event;
			aunit.getUnit().endEmergency();
		} catch (Exception e) {
			throw new IllegalArgumentException(e.toString());
		}
		
	}

	@Override
	public void notifyTimeChanged(ITime time) throws ExternalSystemException,
			IllegalArgumentException {
		// TODO ExternalSystem
		
	}

	/**
	 * Method for notify-ing the external system of updating the time
	 */
	@Override
	public void update(Observable o, Object arg) {
		
	}
}
